//
// Created by 69566 on 25-8-18.
//

#ifndef DATA_MANAGER_H
#define DATA_MANAGER_H

#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>


/* ===================== 宏 ===================== */
#define DATA_BIT_CFG(index, bit_len, bit_offset)                               \
  ((index << 8) + (bit_len << 4) + bit_offset)

typedef struct {
  uint8_t data1;
  uint8_t data2;
  uint16_t data3;
  uint8_t data4;
} xx_data_t;

typedef struct {
  size_t offset;
  size_t size; // 字节数
} data_info_t;

typedef enum {
  DATA1,
  DATA2,
  DATA3,
  DATA4,
  DATA_MAX,
  DATA_BIT1 = DATA_BIT_CFG(DATA4, 1, 0),
  DATA_BIT2 = DATA_BIT_CFG(DATA4, 1, 1),
  DATA_BIT3 = DATA_BIT_CFG(DATA4, 1, 3),
  DATA_MAX_ALL,
} data_index_e;

uint32_t data_get(data_index_e index);
void data_set(data_index_e index, uint8_t value);
#endif // DATA_MANAGER_H
